package cn.edu.ruc.cloudcomputing.forkjoin;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

public class ForkJoinPoolTest {

	 public static void main(String[] args) throws Exception {  
	        // 创建包含Runtime.getRuntime().availableProcessors()返回值作为个数的并行线程的ForkJoinPool  
	        ForkJoinPool forkJoinPool = new ForkJoinPool();  
	        // 提交可分解的PrintTask任务  
	        forkJoinPool.submit(new PrintTask(0, 1000));  
	        forkJoinPool.awaitTermination(2, TimeUnit.SECONDS);//阻塞当前线程直到 ForkJoinPool 中所有的任务都执行结束  
	        // 关闭线程池  
	        forkJoinPool.shutdown();  
	    }  
	 
}
